<?php
/* @var $this AgentRechargeController */
/* @var $model AgentRecharge */
/* @var $form CActiveForm */
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'agent-recharge-form',
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note"><?php echo Yii::t('base','Fields with <span class="required">*</span> are required.');?></p>
        <!-- 充值错误提示 -->
        <p class="red"> <?php
             if($_GET['fail_message'] == 1){
                 echo Yii::t('base', 'Note: payment charged fail.');
             }elseif($_GET['fail_message'] == 2){
                 echo Yii::t('base', 'Note: payment charged fail. No Credit Card information found.');
             }
             if($_GET['message'] == 1){
                 echo Yii::t('base', 'Please bind the bank card,in user management-->list-->bind credit,then recharge.');
             }elseif($_GET['message'] == 2){
                 echo Yii::t('base', 'Please bind the credit card,then recharge.');
             }
        ?></p>
        
	<?php echo $form->errorSummary($model); ?>
        <!-- 如果flag 等于 1  是代理商自充，否则管理员代充 -->
        <?php if($_GET['flag'] != 1){?>
	<div class="row">
		<?php echo $form->labelEx($model,'recharge_time'); ?>
		<input class="Wdate" type="text" name="AgentRecharge[recharge_time]" 
	 value="<?php echo $model->recharge_time=='0000-00-00 00:00:00'?date("Y-m-d H:i:s"):$model->recharge_time;?>" onClick="WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})" />
		<?php echo $form->error($model,'recharge_time'); ?>
	</div>
        <?php }?>

	<div class="row">
		<?php echo $form->labelEx($model,'recharge_number'); ?>
		<?php echo $form->textField($model,'recharge_number'); ?>
		<?php echo $form->error($model,'recharge_number'); ?>
	</div>
         <!-- 如果flag 等于 1  是代理商自充，否则管理员代充 -->
	<?php if($_GET['flag'] != 1){?>
	<div class="row">
		<?php echo $form->labelEx($model,'recharge_type'); ?>
		<?php echo $form->dropDownList($model,'recharge_type',array('4'=>Yii::t('base','cash'),'2'=>Yii::t('base','bank transfer')));//,'3'=>Yii::t('base','remittance') ?>
		<?php echo $form->error($model,'recharge_type'); ?>
	</div>
        <?php }else{?>
        
	<div class="row">
                 <?php echo $form->labelEx($model,'recharge_type'); ?>
                 <?php 
                        $defaultpey = AgentRecharge::model()->getDefaultpay(yii::app()->user->id);
                        echo $form->dropDownList($model,'recharge_type',array('1'=>Yii::t('base','Credit Card'),/*'2'=>Yii::t('base','Direct Debit')*/),array('options' => array($defaultpey=>array('selected'=>true))));//,'3'=>Yii::t('base','remittance')
                    ?>
                 <?php echo $form->error($model,'recharge_type'); ?>
	</div>
        <?php }?>
         
        <div class="row">
		<?php $user_id=yii::app()->request->getParam('user_id');?>
		<?php 
		if($user_id!=""){
                        echo $form->hiddenField($model,'user_id',array('value'=>$user_id)); }else{
			echo $form->hiddenField($model,'user_id',array('value'=>$model->user_id));
		}?>
		<?php echo $form->error($model,'user_id'); ?>
	</div>

	<div class="row">
		<?php 
		if($model->agent_id==""){
			echo $form->hiddenField($model,'agent_id',array('value'=>AgentCompany::model()->getAgentId($user_id))); 
		}else{
			echo $form->hiddenField($model,'agent_id',array('value'=>$model->agent_id));
		}
                ?>
		<?php echo $form->error($model,'agent_id'); ?>
	</div>

        <div class="row">
		<?php // echo $form->labelEx($model,'company_number'); ?>
		<?php echo $form->hiddenField($model,'company_number',array('value'=>AgentRecharge::model()->getCompanyNumber($_GET['user_id']))); ?>
		<?php echo $form->error($model,'company_number'); ?>
	</div>
        
	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? Yii::t('base','Create') : Yii::t('base','Save')); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->